﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using UNYC;

namespace welding
{
    public partial class ConfirmResult : Form
    {
        UNYC.SerialPort.vmSerialPort serialPort;
        UNYC.TcpIp.vmTcpClient vmTcpClient;


        const string strOKA = "OverA";
        const string strNGA = "NGA";
        const string strCancelA = "CancelA";
        const string strRepairA = "RepairA";


        public ConfirmResult(UNYC.SerialPort.vmSerialPort serialPort)
        {
            InitializeComponent();
            this.serialPort = serialPort;
        }
        public ConfirmResult(UNYC.TcpIp.vmTcpClient vmTcpClient)
        {
            InitializeComponent();
            this.vmTcpClient = vmTcpClient;
        }
        public ConfirmResult()
        {
            InitializeComponent();
        }

        private void btnProductCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Ignore;
            this.Close();
        }

        private void btnProductOk_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btnProductNg_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.No;
            this.Close();
        }

        private void btnRepair_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Yes;
            this.Close();
        }

        private void uiTextBoxResult_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                switch (uiTextBoxResult.Text.Trim())
                {
                    case strOKA:
                        btnProductOk_Click(null, null);
                        break;
                    case strNGA:
                        btnProductNg_Click(null, null);
                        break;
                    case strRepairA:
                        btnRepair_Click(null, null);
                        break;
                    case strCancelA:
                        btnProductCancel_Click(null, null);
                        break;

                    default:
                        uiTextBoxResult.SelectAll();
                        break;
                }
            }
        }

        private void ConfirmResult_Load(object sender, EventArgs e)
        {
        }

        private void ConfirmResult_Shown(object sender, EventArgs e)
        {
            uiTextBoxResult.Focus();

        }
    }
}
